﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using EMS20.Entity;
using EMS20.IDataAccessLayer;
using EMS20.DALFactory;

namespace EMS20.BusinessLogicLayer
{
    /// <summary>
    /// BLL Layer For dbo.News.
    /// </summary>
    public class NewsBLLBase
    {
		#region ----------变量定义----------
		///<summary>
		///
		///</summary>
		public static readonly INewsDataAccessLayer _dal=DataAccessFactory.Create_News();
		#endregion
		
		#region ----------构造函数----------
		/// <summary>
		/// 构造函数
		/// </summary>
		public NewsBLLBase()
		{
		}
		#endregion

        #region ----------函数定义----------
		#region 添加更新删除
		/// <summary>
		/// 向数据库中插入一条新记录。
		/// </summary>
		/// <param name="oNewsInfo">News??</param>
		/// <returns>新插入记录的编号</returns>
		public static int Create_NewsInsert(NewsEntity oNewsInfo)
		{
			// Validate input
			if (oNewsInfo == null)
				return 0;
			// Use the dal to insert a new record 
			return _dal.Create_NewsInsert(oNewsInfo);
		}
		/// <summary>
		/// 向数据库中插入一条新记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="oNewsInfo">News实体</param>
		/// <returns>新插入记录的编号</returns>
		public static int Create_NewsInsert(SqlTransaction sp,NewsEntity oNewsInfo)
		{
			if (oNewsInfo == null)
				return 0;
			// Use the dal to insert a new record 
			return _dal.Create_NewsInsert(sp,oNewsInfo);
		}
		/// <summary>
		/// 向数据表News更新一条记录。
		/// </summary>
		/// <param name="oNewsInfo">oNewsInfo</param>
		/// <returns>影响的行数</returns>
		public  static void Create_NewsUpdate(NewsEntity oNewsInfo)
		{
            // Validate input
			if (oNewsInfo==null)
				return;
			// Use the dal to update a new record 
			_dal.Create_NewsUpdate(oNewsInfo);
		}
		/// <summary>
		/// 向数据表News更新一条记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="oNewsInfo">oNewsInfo</param>
		/// <returns>影响的行数</returns>
		public static int Create_NewsUpdate(SqlTransaction sp,NewsEntity oNewsInfo)
		{
			// Validate input
			if (oNewsInfo==null)
				return 0;
			// Use the dal to update a new record 
			return _dal.Create_NewsUpdate(sp,oNewsInfo);
		}
		
		/// <summary>
		/// 删除数据表News中的一条记录
		/// </summary>
	    /// <param name="n_id">n_id</param>
		/// <returns>影响的行数</returns>
		public static int Create_NewsDelete(int n_id)
		{
			// Validate input
			if(n_id<0)
				return 0;
			return _dal.Create_NewsDelete(n_id);
		}
		/// <summary>
		/// 删除数据表News中的一条记录,带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
	    /// <param name="n_id">n_id</param>
		/// <returns>影响的行数</returns>
		public static int Create_NewsDelete(SqlTransaction sp,int n_id)
		{
			// Validate input
			if(n_id<0)
				return 0;
			return _dal.Create_NewsDelete(sp,n_id);
		}
		#endregion
		
        /// <summary>
		/// 得到 news 数据实体
		/// </summary>
		/// <param name="n_id">n_id</param>
		/// <returns>news 数据实体</returns>
		public static NewsEntity Get_NewsEntity(int n_id)
		{
			// Validate input
			if(n_id<0)
				return null;

			// Use the dal to get a record 
			return _dal.Get_NewsEntity(n_id);
		}
		
		/// <summary>
		/// 得到数据表News所有记录
		/// </summary>
		/// <returns>实体集</returns>
		public static IList< NewsEntity> Get_NewsAll()
		{
			// Use the dal to get all records 
			return _dal.Get_NewsAll();
		}
			
		
		/// <summary>
        /// 检测是否存在根据主键
        /// </summary>
        /// <param name="n_id">n_id</param>
        /// <returns>是/否</returns>
		public static bool IsExistNews(int n_id)
		{
			return _dal.IsExistNews(n_id);
		}

        #endregion
		
		
    }
}

